package com.example.competitionregistration.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author QuanJingFang
 * @Description //TODO 响应结果类
 * @Date 2023/7/15 19:48
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private int code;//响应码

    private String msg;//响应信息，成功或失败

    private Object data;//响应数据

    /**
     * @Author QuanJingFang
     * @Description //TODO 无参成功响应结果的方法
     * @Date 2023/7/15 20:01
     * @Param []
     * @return com.example.competitionregistration.entity.Result
     **/
    public static Result success(){
        return new Result(200,"成功",null);
    }

    /**
     * @Author QuanJingFang
     * @Description //TODO 有参成功响应结果的方法
     * @Date 2023/7/15 20:02
     * @Param [data]
     * @return com.example.competitionregistration.entity.Result
     **/
    public static Result success(Object data){
        return new Result(200,"成功",data);
    }

    /**
     * @Author QuanJingFang
     * @Description //TODO 失败响应结果的方法
     * @Date 2023/7/15 20:04
     * @Param [code, msg]
     * @return com.example.competitionregistration.entity.Result
     **/
    public static Result error(int code,String msg){
        return new Result(code,msg,null);
    }
}
